<template>
  <div v-if="isVisible" class="popup" @click="closePopup">
    <div class="popup-content msg" v-if="message" @click.stop>
      <p>{{ message }}</p>
    </div>
    <div class="popup-content" v-else :style="{ 'width': width + 'px' }" @click.stop>
      <HotSongList  :title="'已点歌曲'" :songs="songs" :add="false" />
    </div>
  </div>
</template>

<script setup>
import { defineProps, defineEmits } from 'vue';
import HotSongList from '../HotSongList.vue';

// 定义传入的属性
const props = defineProps({
  message: String,
  songs: Array,
  width: {
    type: Number,
    default: 300
  }
});

const isVisible = defineModel({});

// 定义触发的事件
const emits = defineEmits(['close']);

// 关闭弹出框的方法
const closePopup = () => {
  isVisible.value = false;
  emits('close');
};
</script>

<style scoped>
.popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
}

.popup-content {
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.popup-content.msg {
  background-color: white;
  color: black;
  padding: 20px;
}

.popup-content button {
  margin-top: 10px;
}
</style>